home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / datacces / filetrns / download.frm < prev    next >
Text File  |  1995-12-08  |  31KB  |  978 lines

  1. VERSION 2.00
  2. Begin Form frmDownLoad 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Download Records"
  5.    ClientHeight    =   4650
  6.    ClientLeft      =   315
  7.    ClientTop       =   1635
  8.    ClientWidth     =   9075
  9.    Height          =   5055
  10.    Icon            =   DOWNLOAD.FRX:0000
  11.    Left            =   255
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   540
  16.    ScaleWidth      =   540
  17.    Top             =   1290
  18.    Width           =   9195
  19.    Begin Frame Frame1 
  20.       Caption         =   "Session"
  21.       Height          =   2355
  22.       Left            =   60
  23.       TabIndex        =   18
  24.       Top             =   60
  25.       Width           =   4455
  26.       Begin ComboBox cboSystems 
  27.          FontBold        =   0   'False
  28.          FontItalic      =   0   'False
  29.          FontName        =   "MS Sans Serif"
  30.          FontSize        =   8.25
  31.          FontStrikethru  =   0   'False
  32.          FontUnderline   =   0   'False
  33.          Height          =   300
  34.          Left            =   120
  35.          Style           =   2  'Dropdown List
  36.          TabIndex        =   3
  37.          Top             =   1380
  38.          Width           =   1695
  39.       End
  40.       Begin OptionButton optRetrieve 
  41.          Alignment       =   1  'Right Justify
  42.          Caption         =   "Retrieve Count"
  43.          FontBold        =   0   'False
  44.          FontItalic      =   0   'False
  45.          FontName        =   "MS Sans Serif"
  46.          FontSize        =   8.25
  47.          FontStrikethru  =   0   'False
  48.          FontUnderline   =   0   'False
  49.          Height          =   315
  50.          Index           =   2
  51.          Left            =   2640
  52.          TabIndex        =   37
  53.          Top             =   1920
  54.          Width           =   1695
  55.       End
  56.       Begin OptionButton optRetrieve 
  57.          Alignment       =   1  'Right Justify
  58.          Caption         =   "Retrieve Records"
  59.          FontBold        =   0   'False
  60.          FontItalic      =   0   'False
  61.          FontName        =   "MS Sans Serif"
  62.          FontSize        =   8.25
  63.          FontStrikethru  =   0   'False
  64.          FontUnderline   =   0   'False
  65.          Height          =   315
  66.          Index           =   0
  67.          Left            =   2640
  68.          TabIndex        =   6
  69.          Top             =   1320
  70.          Width           =   1695
  71.       End
  72.       Begin OptionButton optRetrieve 
  73.          Alignment       =   1  'Right Justify
  74.          Caption         =   "Retrieve Templates"
  75.          FontBold        =   0   'False
  76.          FontItalic      =   0   'False
  77.          FontName        =   "MS Sans Serif"
  78.          FontSize        =   8.25
  79.          FontStrikethru  =   0   'False
  80.          FontUnderline   =   0   'False
  81.          Height          =   315
  82.          Index           =   1
  83.          Left            =   2640
  84.          TabIndex        =   7
  85.          Top             =   1620
  86.          Width           =   1695
  87.       End
  88.       Begin CommandButton cmdClose 
  89.          Caption         =   "Close"
  90.          Enabled         =   0   'False
  91.          FontBold        =   0   'False
  92.          FontItalic      =   0   'False
  93.          FontName        =   "MS Sans Serif"
  94.          FontSize        =   8.25
  95.          FontStrikethru  =   0   'False
  96.          FontUnderline   =   0   'False
  97.          Height          =   435
  98.          Left            =   3480
  99.          TabIndex        =   5
  100.          Top             =   780
  101.          Width           =   855
  102.       End
  103.       Begin TextBox txtFile 
  104.          FontBold        =   0   'False
  105.          FontItalic      =   0   'False
  106.          FontName        =   "MS Sans Serif"
  107.          FontSize        =   8.25
  108.          FontStrikethru  =   0   'False
  109.          FontUnderline   =   0   'False
  110.          Height          =   285
  111.          Left            =   1260
  112.          TabIndex        =   1
  113.          Top             =   840
  114.          Width           =   1035
  115.       End
  116.       Begin TextBox txtLibrary 
  117.          FontBold        =   0   'False
  118.          FontItalic      =   0   'False
  119.          FontName        =   "MS Sans Serif"
  120.          FontSize        =   8.25
  121.          FontStrikethru  =   0   'False
  122.          FontUnderline   =   0   'False
  123.          Height          =   285
  124.          Left            =   120
  125.          TabIndex        =   0
  126.          Top             =   840
  127.          Width           =   1095
  128.       End
  129.       Begin TextBox txtMember 
  130.          FontBold        =   0   'False
  131.          FontItalic      =   0   'False
  132.          FontName        =   "MS Sans Serif"
  133.          FontSize        =   8.25
  134.          FontStrikethru  =   0   'False
  135.          FontUnderline   =   0   'False
  136.          Height          =   285
  137.          Left            =   2340
  138.          TabIndex        =   2
  139.          Top             =   840
  140.          Width           =   1035
  141.       End
  142.       Begin CommandButton cmdOpen 
  143.          Caption         =   "Open"
  144.          FontBold        =   0   'False
  145.          FontItalic      =   0   'False
  146.          FontName        =   "MS Sans Serif"
  147.          FontSize        =   8.25
  148.          FontStrikethru  =   0   'False
  149.          FontUnderline   =   0   'False
  150.          Height          =   435
  151.          Left            =   3480
  152.          TabIndex        =   4
  153.          Top             =   300
  154.          Width           =   855
  155.       End
  156.       Begin Label zlbl 
  157.          BackStyle       =   0  'Transparent
  158.          Caption         =   "System:"
  159.          FontBold        =   0   'False
  160.          FontItalic      =   0   'False
  161.          FontName        =   "MS Sans Serif"
  162.          FontSize        =   8.25
  163.          FontStrikethru  =   0   'False
  164.          FontUnderline   =   0   'False
  165.          Height          =   225
  166.          Index           =   12
  167.          Left            =   120
  168.          TabIndex        =   38
  169.          Top             =   1170
  170.          Width           =   615
  171.       End
  172.       Begin Label zlbl 
  173.          Alignment       =   1  'Right Justify
  174.          BackColor       =   &H00FFFFFF&
  175.          BackStyle       =   0  'Transparent
  176.          Caption         =   "Number Of Fields:"
  177.          FontBold        =   0   'False
  178.          FontItalic      =   0   'False
  179.          FontName        =   "MS Sans Serif"
  180.          FontSize        =   8.25
  181.          FontStrikethru  =   0   'False
  182.          FontUnderline   =   0   'False
  183.          ForeColor       =   &H00000000&
  184.          Height          =   255
  185.          Index           =   6
  186.          Left            =   120
  187.          TabIndex        =   20
  188.          Top             =   1980
  189.          Width           =   1335
  190.       End
  191.       Begin Label lblNumFields 
  192.          FontBold        =   0   'False
  193.          FontItalic      =   0   'False
  194.          FontName        =   "MS Sans Serif"
  195.          FontSize        =   8.25
  196.          FontStrikethru  =   0   'False
  197.          FontUnderline   =   0   'False
  198.          Height          =   255
  199.          Left            =   1500
  200.          TabIndex        =   21
  201.          Top             =   1980
  202.          Width           =   795
  203.       End
  204.       Begin Label zlbl 
  205.          Alignment       =   1  'Right Justify
  206.          BackColor       =   &H00FFFFFF&
  207.          BackStyle       =   0  'Transparent
  208.          Caption         =   "Conversation ID:"
  209.          FontBold        =   0   'False
  210.          FontItalic      =   0   'False
  211.          FontName        =   "MS Sans Serif"
  212.          FontSize        =   8.25
  213.          FontStrikethru  =   0   'False
  214.          FontUnderline   =   0   'False
  215.          ForeColor       =   &H00000000&
  216.          Height          =   255
  217.          Index           =   7
  218.          Left            =   120
  219.          TabIndex        =   22
  220.          Top             =   1740
  221.          Width           =   1335
  222.       End
  223.       Begin Label lblConvID 
  224.          FontBold        =   0   'False
  225.          FontItalic      =   0   'False
  226.          FontName        =   "MS Sans Serif"
  227.          FontSize        =   8.25
  228.          FontStrikethru  =   0   'False
  229.          FontUnderline   =   0   'False
  230.          Height          =   255
  231.          Left            =   1500
  232.          TabIndex        =   23
  233.          Top             =   1740
  234.          Width           =   915
  235.       End
  236.       Begin Label zlbl 
  237.          Alignment       =   2  'Center
  238.          BackColor       =   &H00800000&
  239.          Caption         =   "File"
  240.          ForeColor       =   &H00FFFFFF&
  241.          Height          =   255
  242.          Index           =   1
  243.          Left            =   1260
  244.          TabIndex        =   24
  245.          Top             =   600
  246.          Width           =   1035
  247.       End
  248.       Begin Label zlbl 
  249.          Alignment       =   2  'Center
  250.          BackColor       =   &H00800000&
  251.          Caption         =   "Library"
  252.          ForeColor       =   &H00FFFFFF&
  253.          Height          =   255
  254.          Index           =   0
  255.          Left            =   120
  256.          TabIndex        =   25
  257.          Top             =   600
  258.          Width           =   1095
  259.       End
  260.       Begin Label zlbl 
  261.          Alignment       =   2  'Center
  262.          BackColor       =   &H00800000&
  263.          Caption         =   "Member"
  264.          ForeColor       =   &H00FFFFFF&
  265.          Height          =   255
  266.          Index           =   2
  267.          Left            =   2340
  268.          TabIndex        =   26
  269.          Top             =   600
  270.          Width           =   1035
  271.       End
  272.       Begin Label lblSessionStatus 
  273.          Alignment       =   2  'Center
  274.          BackColor       =   &H000000FF&
  275.          BorderStyle     =   1  'Fixed Single
  276.          Caption         =   "Transfer Session Closed"
  277.          Height          =   255
  278.          Left            =   120
  279.          TabIndex        =   28
  280.          Top             =   300
  281.          Width           =   3255
  282.       End
  283.    End
  284.    Begin Frame fraReturned 
  285.       Caption         =   "Information Returned"
  286.       Height          =   3555
  287.       Left            =   4560
  288.       TabIndex        =   29
  289.       Top             =   60
  290.       Width           =   4455
  291.       Begin TextBox txtReturned 
  292.          FontBold        =   0   'False
  293.          FontItalic      =   0   'False
  294.          FontName        =   "MS Sans Serif"
  295.          FontSize        =   8.25
  296.          FontStrikethru  =   0   'False
  297.          FontUnderline   =   0   'False
  298.          Height          =   2355
  299.          Left            =   60
  300.          MultiLine       =   -1  'True
  301.          ScrollBars      =   2  'Vertical
  302.          TabIndex        =   32
  303.          TabStop         =   0   'False
  304.          Top             =   1140
  305.          Width           =   4335
  306.       End
  307.       Begin Label lblReturned 
  308.          Alignment       =   2  'Center
  309.          BackColor       =   &H00800000&
  310.          Caption         =   "Error Message"
  311.          ForeColor       =   &H00FFFFFF&
  312.          Height          =   255
  313.          Left            =   60
  314.          TabIndex        =   33
  315.          Top             =   900
  316.          Width           =   4335
  317.       End
  318.       Begin Label zlbl 
  319.          Alignment       =   1  'Right Justify
  320.          BackColor       =   &H00FFFFFF&
  321.          BackStyle       =   0  'Transparent
  322.          Caption         =   "API Return Code:"
  323.          FontBold        =   0   'False
  324.          FontItalic      =   0   'False
  325.          FontName        =   "MS Sans Serif"
  326.          FontSize        =   8.25
  327.          FontStrikethru  =   0   'False
  328.          FontUnderline   =   0   'False
  329.          ForeColor       =   &H00000000&
  330.          Height          =   255
  331.          Index           =   8
  332.          Left            =   60
  333.          TabIndex        =   36
  334.          Top             =   300
  335.          Width           =   1275
  336.       End
  337.       Begin Label lblReturnCode 
  338.          FontBold        =   0   'False
  339.          FontItalic      =   0   'False
  340.          FontName        =   "MS Sans Serif"
  341.          FontSize        =   8.25
  342.          FontStrikethru  =   0   'False
  343.          FontUnderline   =   0   'False
  344.          Height          =   255
  345.          Left            =   1380
  346.          TabIndex        =   19
  347.          Top             =   300
  348.          Width           =   735
  349.       End
  350.       Begin Label zlbl 
  351.          Alignment       =   1  'Right Justify
  352.          BackColor       =   &H00FFFFFF&
  353.          BackStyle       =   0  'Transparent
  354.          Caption         =   "Blocks Written:"
  355.          FontBold        =   0   'False
  356.          FontItalic      =   0   'False
  357.          FontName        =   "MS Sans Serif"
  358.          FontSize        =   8.25
  359.          FontStrikethru  =   0   'False
  360.          FontUnderline   =   0   'False
  361.          ForeColor       =   &H00000000&
  362.          Height          =   255
  363.          Index           =   4
  364.          Left            =   2160
  365.          TabIndex        =   35
  366.          Top             =   600
  367.          Width           =   1155
  368.       End
  369.       Begin Label zlbl 
  370.          Alignment       =   1  'Right Justify
  371.          BackColor       =   &H00FFFFFF&
  372.          BackStyle       =   0  'Transparent
  373.          Caption         =   "Records Read:"
  374.          FontBold        =   0   'False
  375.          FontItalic      =   0   'False
  376.          FontName        =   "MS Sans Serif"
  377.          FontSize        =   8.25
  378.          FontStrikethru  =   0   'False
  379.          FontUnderline   =   0   'False
  380.          ForeColor       =   &H00000000&
  381.          Height          =   255
  382.          Index           =   3
  383.          Left            =   2160
  384.          TabIndex        =   34
  385.          Top             =   300
  386.          Width           =   1155
  387.       End
  388.       Begin Label lblBlocksWritten 
  389.          Alignment       =   2  'Center
  390.          FontBold        =   0   'False
  391.          FontItalic      =   0   'False
  392.          FontName        =   "MS Sans Serif"
  393.          FontSize        =   8.25
  394.          FontStrikethru  =   0   'False
  395.          FontUnderline   =   0   'False
  396.          Height          =   255
  397.          Left            =   3360
  398.          TabIndex        =   31
  399.          Top             =   600
  400.          Width           =   735
  401.       End
  402.       Begin Label lblRecordsRead 
  403.          Alignment       =   2  'Center
  404.          FontBold        =   0   'False
  405.          FontItalic      =   0   'False
  406.          FontName        =   "MS Sans Serif"
  407.          FontSize        =   8.25
  408.          FontStrikethru  =   0   'False
  409.          FontUnderline   =   0   'False
  410.          Height          =   255
  411.          Left            =   3360
  412.          TabIndex        =   30
  413.          Top             =   300
  414.          Width           =   735
  415.       End
  416.    End
  417.    Begin Frame fraConversion 
  418.       Caption         =   "Retrieval"
  419.       Height          =   2175
  420.       Left            =   60
  421.       TabIndex        =   27
  422.       Top             =   2400
  423.       Width           =   4455
  424.       Begin CommandButton cmdStart 
  425.          Caption         =   "Start"
  426.          Enabled         =   0   'False
  427.          FontBold        =   0   'False
  428.          FontItalic      =   0   'False
  429.          FontName        =   "MS Sans Serif"
  430.          FontSize        =   8.25
  431.          FontStrikethru  =   0   'False
  432.          FontUnderline   =   0   'False
  433.          Height          =   435
  434.          Left            =   3480
  435.          TabIndex        =   14
  436.          Top             =   180
  437.          Width           =   855
  438.       End
  439.       Begin CommandButton cmdEnd 
  440.          Caption         =   "End"
  441.          Enabled         =   0   'False
  442.          FontBold        =   0   'False
  443.          FontItalic      =   0   'False
  444.          FontName        =   "MS Sans Serif"
  445.          FontSize        =   8.25
  446.          FontStrikethru  =   0   'False
  447.          FontUnderline   =   0   'False
  448.          Height          =   435
  449.          Left            =   3480
  450.          TabIndex        =   15
  451.          Top             =   660
  452.          Width           =   855
  453.       End
  454.       Begin CheckBox chkHandleNulls 
  455.          Alignment       =   1  'Right Justify
  456.          Caption         =   "Handle Null Fields"
  457.          Height          =   315
  458.          Left            =   2460
  459.          TabIndex        =   13
  460.          Top             =   1800
  461.          Width           =   1875
  462.       End
  463.       Begin OptionButton optConversion 
  464.          Caption         =   "DOS Random Type 2, with Exceptions"
  465.          FontBold        =   0   'False
  466.          FontItalic      =   0   'False
  467.          FontName        =   "MS Sans Serif"
  468.          FontSize        =   8.25
  469.          FontStrikethru  =   0   'False
  470.          FontUnderline   =   0   'False
  471.          Height          =   372
  472.          Index           =   4
  473.          Left            =   60
  474.          TabIndex        =   12
  475.          Top             =   1440
  476.          Width           =   3012
  477.       End
  478.       Begin OptionButton optConversion 
  479.          Caption         =   "DOS Random Type 2"
  480.          FontBold        =   0   'False
  481.          FontItalic      =   0   'False
  482.          FontName        =   "MS Sans Serif"
  483.          FontSize        =   8.25
  484.          FontStrikethru  =   0   'False
  485.          FontUnderline   =   0   'False
  486.          Height          =   375
  487.          Index           =   3
  488.          Left            =   60
  489.          TabIndex        =   10
  490.          Top             =   840
  491.          Width           =   1875
  492.       End
  493.       Begin OptionButton optConversion 
  494.          Caption         =   "DOS Random, with Exceptions"
  495.          FontBold        =   0   'False
  496.          FontItalic      =   0   'False
  497.          FontName        =   "MS Sans Serif"
  498.          FontSize        =   8.25
  499.          FontStrikethru  =   0   'False
  500.          FontUnderline   =   0   'False
  501.          Height          =   375
  502.          Index           =   2
  503.          Left            =   60
  504.          TabIndex        =   11
  505.          Top             =   1140
  506.          Width           =   2535
  507.       End
  508.       Begin OptionButton optConversion 
  509.          Caption         =   "DOS Random"
  510.          FontBold        =   0   'False
  511.          FontItalic      =   0   'False
  512.          FontName        =   "MS Sans Serif"
  513.          FontSize        =   8.25
  514.          FontStrikethru  =   0   'False
  515.          FontUnderline   =   0   'False
  516.          Height          =   375
  517.          Index           =   1
  518.          Left            =   60
  519.          TabIndex        =   9
  520.          Top             =   540
  521.          Width           =   1875
  522.       End
  523.       Begin OptionButton optConversion 
  524.          Caption         =   "No Conversion"
  525.          FontBold        =   0   'False
  526.          FontItalic      =   0   'False
  527.          FontName        =   "MS Sans Serif"
  528.          FontSize        =   8.25
  529.          FontStrikethru  =   0   'False
  530.          FontUnderline   =   0   'False
  531.          Height          =   375
  532.          Index           =   0
  533.          Left            =   60
  534.          TabIndex        =   8
  535.          Top             =   240
  536.          Width           =   1875
  537.       End
  538.    End
  539.    Begin CommandButton cmdAbout 
  540.       Caption         =   "&About"
  541.       FontBold        =   0   'False
  542.       FontItalic      =   0   'False
  543.       FontName        =   "MS Sans Serif"
  544.       FontSize        =   8.25
  545.       FontStrikethru  =   0   'False
  546.       FontUnderline   =   0   'False
  547.       Height          =   435
  548.       Left            =   8100
  549.       TabIndex        =   16
  550.       Top             =   3660
  551.       Width           =   855
  552.    End
  553.    Begin CommandButton cmdExit 
  554.       Caption         =   "E&xit"
  555.       FontBold        =   0   'False
  556.       FontItalic      =   0   'False
  557.       FontName        =   "MS Sans Serif"
  558.       FontSize        =   8.25
  559.       FontStrikethru  =   0   'False
  560.       FontUnderline   =   0   'False
  561.       Height          =   435
  562.       Left            =   8100
  563.       TabIndex        =   17
  564.       Top             =   4140
  565.       Width           =   855
  566.    End
  567. End
  568. Option Explicit
  569.  
  570.  ' Constants:
  571.   Const sSTATUS_OFF = "Transfer Session Closed"
  572.   Const sSTATUS_ON = "Transfer Session Open"
  573.  
  574.  ' Variables:
  575.   Dim bStopRetrieval             As Integer  ' stop retrieval
  576.   Dim lTFConvID                  As Long     ' conversation ID
  577.   Dim lRecordsRead               As Long     ' records read
  578.   Dim nBlocksWritten             As Integer  ' blocks written
  579.   Dim nFileNumber                As Integer  ' open file number
  580.   Dim nRC                        As Integer  ' API return code
  581.   Dim sRecord                    As String   ' record read
  582.   Dim sRecordsToBeWritten        As String   ' records to be written to disk
  583.   Dim sSystem                    As String   ' AS/400 system name
  584.  
  585. Sub cmdAbout_Click ()
  586.  
  587.   ' display about message
  588.   gsMBText = "This program will download a file from your AS/400"
  589.   gsMBText = gsMBText & " into an ASCII text file called DOWNLOAD.TXT"
  590.   gsMBText = gsMBText & " or field information into a file called TEMPLATE.TXT."
  591.   MsgBox gsMBText
  592.  
  593. End Sub
  594.  
  595. Sub cmdClose_Click ()
  596.  
  597.   Call SessionClose
  598.  
  599. End Sub
  600.  
  601. Sub cmdEnd_Click ()
  602.   
  603.   ' end current retrieval process
  604.   bStopRetrieval = True
  605.  
  606.   ' cannot end any more
  607.   cmdStart.Enabled = True
  608.   cmdEnd.Enabled = False
  609.   
  610. End Sub
  611.  
  612. Sub cmdExit_Click ()
  613.  
  614.   ' unload form
  615.   If MsgBox("Do You Want To End The Program?", MB_ICONQUESTION Or MB_YESNO) = IDYES Then Unload Me
  616.  
  617. End Sub
  618.  
  619. Sub cmdOpen_Click ()
  620.  
  621.   ' open file transfer session
  622.   Call SessionOpen
  623.   
  624. End Sub
  625.  
  626. Sub cmdStart_Click ()
  627.  
  628.   ' retrieving records or templates
  629.   Call RetrieveStart
  630.  
  631. End Sub
  632.  
  633. Sub Form_Load ()
  634.  
  635.   ' set global variables
  636.   Call zzSetGlobalVariables
  637.  
  638.   ' center form
  639.   zzFormCenter Me
  640.  
  641.   ' setup program title
  642.   App.Title = "Download Records"
  643.  
  644.   ' put list of systems into control
  645.   Call zzCAPutSystemListIntoCtrl(Me.hWnd, cboSystems)
  646.   
  647.   ' turn on options
  648.   optRetrieve(0) = True
  649.   optConversion(0) = True
  650.   chkHandleNulls = False
  651.   lblReturned = "This Area Will Display Error Messages And Data"
  652.  
  653.   ' assume session closed
  654.   Call SessionClose
  655.   
  656. End Sub
  657.  
  658. Sub Form_Unload (Cancel As Integer)
  659.  
  660.   ' close open session
  661.   Call SessionClose
  662.  
  663.   ' end program
  664.   End
  665.  
  666. End Sub
  667.  
  668. Sub RetrieveStart ()
  669.  
  670.  ' Description:
  671.  '  Retrieve records or templates
  672.  
  673.  ' Parameters:
  674.  '  bRetrieveRecords          retrieve records
  675.  
  676.  ' Variables:
  677.   Dim nTFConversion           As Integer  ' conversion option
  678.   Dim bRetrieveCount          As Integer  ' retrieving count?
  679.   Dim bRetrieveRecords        As Integer  ' retrieving records
  680.   
  681.   ' template information
  682.   Dim nFieldDecimalPos      As Integer
  683.   Dim nFieldDigits          As Integer
  684.   Dim nFieldLength          As Integer
  685.   Dim nFieldNullCapable     As Integer
  686.   Dim nFieldType            As Integer
  687.   Dim nFieldVariableLength  As Integer
  688.   Dim sFieldName            As String
  689.  
  690.   ' are we retrieving records
  691.   bRetrieveRecords = ((optRetrieve(0) <> False) Or (optRetrieve(2) <> False))
  692.   
  693.   ' are we getting a count of records
  694.   bRetrieveCount = (optRetrieve(2) <> False)
  695.   
  696.   nFileNumber = FreeFile
  697.  
  698.   ' open download file if just retrieving records
  699.   If bRetrieveRecords And Not bRetrieveCount Then
  700.     Open App.Path & "\DOWNLOAD.TXT" For Output As nFileNumber
  701.     lblReturned = "Current Record"
  702.  
  703.   ' do nothing if getting count
  704.   ElseIf bRetrieveCount Then
  705.     lblReturned = "Record Count"
  706.   
  707.   ' open template file
  708.   Else
  709.     Open App.Path & "\TEMPLATE.TXT" For Output As nFileNumber
  710.     lblReturned = "Current Template"
  711.   End If
  712.  
  713.   ' clear storage field, counters
  714.   sRecordsToBeWritten = gsEMPTY
  715.   nBlocksWritten = 0: lRecordsRead = 0
  716.  
  717.   ' determine conversion option
  718.   If optConversion(0) Then
  719.     nTFConversion = gnTF_NO_CONVERSION
  720.   ElseIf optConversion(1) Then
  721.     nTFConversion = gnTF_DOS_RANDOM
  722.   ElseIf optConversion(2) Then
  723.     nTFConversion = gnTF_DOS_RANDOM2
  724.   ElseIf optConversion(3) Then
  725.     nTFConversion = gnTF_DOS_RANDOM_EXCEPT
  726.   ElseIf optConversion(4) Then
  727.     nTFConversion = gnTF_DOS_RANDOM2_EXCEPT
  728.   End If
  729.  
  730.   ' handle nulls
  731.   If chkHandleNulls Then
  732.     nTFConversion = nTFConversion + &H80
  733.   End If
  734.  
  735.   ' no conversion if getting count
  736.   If bRetrieveCount Then
  737.     nTFConversion = gnTF_NO_CONVERSION
  738.   End If
  739.  
  740.   ' start current retrieval process
  741.   bStopRetrieval = False
  742.   cmdStart.Enabled = False
  743.   cmdEnd.Enabled = True
  744.   
  745.   Do
  746.  
  747.     ' give windows time
  748.     DoEvents
  749.  
  750.     ' stop current retrieval process
  751.     If bStopRetrieval Then Exit Do
  752.  
  753.     ' retrieve record
  754.     If bRetrieveRecords Then
  755.       nRC = zzTFGetRecord(Me.hWnd, 0, lTFConvID, cboSystems.Text, nTFConversion, sRecord)
  756.     
  757.     ' retrieve template
  758.     Else
  759.       
  760.       nRC = zzTFGetTemplate(Me.hWnd, 0, lTFConvID, cboSystems.Text, sRecord)
  761.     
  762.       ' break down field specs
  763.       Call zzTFParseTemplate(sRecord, sFieldName, nFieldType, nFieldDigits, nFieldDecimalPos, nFieldLength, nFieldNullCapable, nFieldVariableLength)
  764.       sRecord = sFieldName & ", Length:"
  765.       sRecord = sRecord & Format$(nFieldLength) & "."
  766.       sRecord = sRecord & Format$(nFieldDecimalPos) & ", Type:"
  767.       sRecord = sRecord & Format$(nFieldType)
  768.       
  769.     End If
  770.  
  771.     ' show return code
  772.     lblReturnCode = Hex$(nRC)
  773.         
  774.     ' if EOF then exit
  775.     If nRC = gnTF_EOF Then Exit Do
  776.  
  777.     ' if any other error except untranslatable data then exit
  778.     If nRC <> gnTF_OK And nRC <> gnTF_UNXLATABLE_DATA Then Exit Do
  779.     
  780.     ' increment and show counter
  781.     lRecordsRead = lRecordsRead + 1
  782.     lblRecordsRead = Format$(lRecordsRead)
  783.  
  784.     ' convert the count of records
  785.     If bRetrieveCount Then
  786.       sRecord = zzCV_Bin4ToASCII(Me.hWnd, sRecord) & " records in file."
  787.     End If
  788.       
  789.     ' show data returned
  790.     txtReturned = sRecord
  791.  
  792.     ' add to storage area with EOL stuff
  793.     sRecordsToBeWritten = sRecordsToBeWritten & sRecord & gsCHR_CR & gsCHR_LF
  794.       
  795.     ' if big enough then write it out
  796.     If Len(sRecordsToBeWritten) > 10000 Then
  797.       Print #nFileNumber, sRecordsToBeWritten;
  798.       sRecordsToBeWritten = gsEMPTY
  799.       nBlocksWritten = nBlocksWritten + 1
  800.       lblBlocksWritten = Format$(nBlocksWritten)
  801.     End If
  802.       
  803.   Loop
  804.  
  805.   ' handle errors
  806.   On Error Resume Next
  807.  
  808.   ' write out any left over data
  809.   If sRecordsToBeWritten <> gsEMPTY Then
  810.     Print #nFileNumber, sRecordsToBeWritten
  811.   End If
  812.   
  813.   ' close the output file
  814.   Close nFileNumber
  815.  
  816.   ' end retrieval
  817.   cmdEnd = True
  818.  
  819. End Sub
  820.  
  821. Sub SessionClose ()
  822.   
  823.   MousePointer = HOURGLASS
  824.     
  825.   ' if session already open then
  826.   If lTFConvID <> 0 Then
  827.  
  828.     ' close any active transfer requests
  829.     nRC = zzTFClose(Me.hWnd, 0, lTFConvID, cboSystems.Text)
  830.     
  831.     ' end conversation
  832.     nRC = zzTFEndConversation(Me.hWnd, 0, lTFConvID, cboSystems.Text)
  833.  
  834.     ' turn status flag off
  835.     lblSessionStatus = sSTATUS_OFF
  836.     lblSessionStatus.BackColor = RED
  837.  
  838.     ' reset conversation ID
  839.     lTFConvID = 0
  840.  
  841.     ' cannot open again
  842.     cmdOpen.Enabled = True
  843.     cboSystems.Enabled = True
  844.     cmdClose.Enabled = False
  845.     cmdStart.Enabled = False
  846.     cmdEnd.Enabled = False
  847.  
  848.   End If
  849.  
  850.   ' display returned information
  851.   If lTFConvID = 0 Then
  852.     lblConvID = gsEMPTY
  853.   Else
  854.     lblConvID = Format$(lTFConvID)
  855.   End If
  856.   If nRC = gnTF_OK Then
  857.     lblReturnCode = gsEMPTY
  858.   Else
  859.     lblReturnCode = Hex$(nRC)
  860.   End If
  861.   
  862.   lblNumFields = gsEMPTY
  863.   txtReturned = gsEMPTY
  864.   lblRecordsRead = gsEMPTY
  865.   lblBlocksWritten = gsEMPTY
  866.  
  867.   MousePointer = DEFAULT
  868.     
  869. End Sub
  870.  
  871. Sub SessionOpen ()
  872.  
  873.  ' Description:
  874.  '  Open transfer session
  875.  
  876.  ' Variables:
  877.   Dim nTFNumTemplates      As Integer      ' number of templates
  878.   Dim sSelectStatement     As String       ' select statement
  879.   Dim sSelectStatementSent As String       ' select statement
  880.  
  881.   ' close current session
  882.   Call SessionClose
  883.  
  884.   ' must have library name
  885.   If cboSystems.Text = gsEMPTY Then
  886.     gsMBText = "AS/400 system required."
  887.     MsgBox gsMBText, MB_ICONSTOP
  888.     cboSystems.SetFocus
  889.     
  890.   Else
  891.       
  892.     ' must have library name
  893.     If txtLibrary = gsEMPTY Then
  894.       gsMBText = "Library name required."
  895.       MsgBox gsMBText, MB_ICONSTOP
  896.       txtLibrary.SetFocus
  897.     
  898.     Else
  899.       
  900.       ' must have file name
  901.       If txtFile = gsEMPTY Then
  902.         gsMBText = "File name required."
  903.         MsgBox gsMBText, MB_ICONSTOP
  904.         txtFile.SetFocus
  905.       
  906.       Else
  907.   
  908.         ' please wait
  909.         MousePointer = HOURGLASS
  910.   
  911.         ' just getting count of records
  912.         If optRetrieve(2) = True Then
  913.           sSelectStatement = "SELECT COUNT(*) FROM " & UCase$(txtLibrary) & "/" & UCase$(txtFile)
  914.   
  915.         ' getting templates or records
  916.         Else
  917.           sSelectStatement = "SELECT * FROM " & UCase$(txtLibrary) & "/" & UCase$(txtFile)
  918.         End If
  919.   
  920.         ' add member information
  921.         If txtMember <> gsEMPTY Then
  922.           sSelectStatement = sSelectStatement & " (" & UCase$(txtMember) & ")"
  923.         End If
  924.         
  925.         ' place in select statement to send
  926.         sSelectStatementSent = sSelectStatement
  927.       
  928.         ' send SELECT statement to host
  929.         nRC = zzTFOpen(Me.hWnd, 0, lTFConvID, sSelectStatement, cboSystems.Text, nTFNumTemplates)
  930.         
  931.         ' no more waiting
  932.         MousePointer = DEFAULT
  933.   
  934.         ' show resulting select statement
  935.         If nRC = gnTF_OK Then
  936.           lblReturned = "Formatted Select Statement"
  937.           txtReturned = sSelectStatement
  938.         Else
  939.           lblReturned = "Error Message"
  940.           If sSelectStatementSent <> sSelectStatement Then
  941.             txtReturned = sSelectStatement
  942.           Else
  943.             txtReturned = gsEMPTY
  944.           End If
  945.         End If
  946.         
  947.         ' display return information
  948.         lblConvID = Format$(lTFConvID)
  949.         lblReturnCode = Hex$(nRC)
  950.         If nRC = gnTF_OK Then
  951.           lblNumFields = Format$(nTFNumTemplates)
  952.         Else
  953.           lblNumFields = gsEMPTY
  954.         End If
  955.         
  956.         If lTFConvID <> 0 Then
  957.         
  958.           ' turn status flag on
  959.           lblSessionStatus = sSTATUS_ON
  960.           lblSessionStatus.BackColor = GREEN
  961.   
  962.           ' cannot open again
  963.           cmdOpen.Enabled = False
  964.           cboSystems.Enabled = False
  965.           cmdClose.Enabled = True
  966.           cmdStart.Enabled = True
  967.   
  968.         End If
  969.     
  970.       End If
  971.   
  972.     End If
  973.   
  974.   End If
  975.  
  976. End Sub
  977.  
  978.